package com.kygl.sys.util;

import com.kygl.sys.util.vo.ActionPage;

public class ActionPageUtil {
	
	public static ActionPage refererInit(ActionPage ap) {
		String refererUrl,workingUrl;
		refererUrl = (String) ap.getAc().getSession()
				.get("refererUrl");
		workingUrl = (String) ap.getAc().getSession()
				.get("workingUrl");
		if (workingUrl == null || workingUrl.trim().equals("")
				|| workingUrl.trim().equals("null")) {
			if (ap.getRequest().getHeader("Referer") == null) {
				workingUrl = ap.getRequest().getContextPath() + "/"
						+ ap.getActionSupport().getText("lerx.defaultReturnSiteUrl");

			} else {
				workingUrl = ap.getRequest().getHeader("Referer");
			}

		}

		if (refererUrl == null || refererUrl.trim().equals("")
				|| refererUrl.trim().equals("null")) {

			if (ap.getRequest().getHeader("Referer") == null) {
				refererUrl = ap.getRequest().getContextPath() + "/"
						+ ap.getActionSupport().getText("lerx.defaultReturnSiteUrl");

			} else {
				refererUrl = ap.getRequest().getHeader("Referer");
			}

		}
		
		ap.setRefererUrl(refererUrl);
		ap.setWorkingUrl(workingUrl);
		
		return ap;
		
	}
}
